<?php
/**
 * Date: 09.06.14
 */

class sideMenuWidget extends CWidget
{
    public $product;

    public function init()
    {

    }

    public function run()
    {
        $this->runWidget();
    }

    public function runWidget()
    {

        echo "<tr>";
        echo "<td style='width: 200px;'>";
        if ($this->product->image){

            echo "<div><img style='height: 150px !important' class='img-thumbnail' width='150' height='150' src='".Yii::app()->request->baseUrl."/images/".$this->product->image."' /></div>";

        }
        echo "</td>";
        echo "<td>";
        echo "<h4>" . $this->product->title . "</h4>";
        echo "<div>Наличие: " . $this->isPresent($this->product->is_present) . "</div>";
        if ($this->product->is_present){
        echo "<div>Цена: " . $this->product->price . "</div>";
        echo "<div>" . CHtml::link("Добавить в корзину", '#', array('submit'=>array("/dobavit_v_korzinu/"), 'params'=>array('id'=>$this->product->id))) . "</div>";
        }
        echo "<div>" . CHtml::link("Подробнее", Yii::app()->createUrl("/tovar/".$this->product->id)) . "</div>";

        echo "</td>";
        echo "</tr>";

    }

    public function isPresent($is_present)
    {
        return $is_present ? "Есть в наличии" : "Нет в наличии";
    }
} 